import * as actionTypes from "./constance";

import {
  commentVideo,
  videoDetail,
  videoUrl,
  videoDetailInfo,
  allvideo,
} from "@/services/video";

const commentVideoInfo = (res) => ({
  type: actionTypes.GET_VIDEO,
  videoComment: res,
});
const videoDetails = (res) => ({
  type: actionTypes.GET_VIDEODETAIL,
  videoDetail: res,
});
const videoUrlInfo = (res) => ({
  type: actionTypes.GET_VIDEOURL,
  videoUrl: res,
});
const videoDetailInfoS = (res) => ({
  type: actionTypes.GET_VIDEODETAILINFO,
  videoDetailInfo: res,
});
const allvideoInfo = (res) => ({
  type: actionTypes.GET_MV_ALLVEDIO,
  allVideo: res,
});

export const commentVideoAction = (id, limit, offset, before) => {
  return (dispatch) => {
    commentVideo(id, limit, offset, before).then((res) => {
      dispatch(commentVideoInfo(res));
    });
  };
};
export const videoDetailAction = (id) => {
  return (dispatch) => {
    videoDetail(id).then((res) => {
      dispatch(videoDetails(res));
    });
  };
};
export const videoUrlAction = (id, limit, offset, before) => {
  return (dispatch) => {
    videoUrl(id).then((res) => {
      dispatch(videoUrlInfo(res));
    });
  };
};
export const videoDetailInfoAction = (vid) => {
  return (dispatch) => {
    videoDetailInfo(vid).then((res) => {
      dispatch(videoDetailInfoS(res));
    });
  };
};
export const allvideoAction = (id) => {
  return (dispatch) => {
    allvideo(id).then((res) => {
      dispatch(allvideoInfo(res));
    });
  };
};
